package com.guldan.auth.provider.core;

import com.guldan.core.spring.ContextHolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created by Silas.
 * Date: 2016/10/2
 * Time: 0:35
 */
public class Start {

    protected static Logger logger = LoggerFactory.getLogger(Start.class);

    public static boolean STARTED = false;

    /*程序入口*/
    public static void main(String[] args) {

        try {
            logger.warn("start run auth provider.");
            ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath*:/spring/app-context-*.xml");
            ContextHolder.setCtx(context);
            context.start();
            logger.warn("auth provider started successfully.");
            STARTED = true;
            synchronized (Start.class) {
                while (true) {
                    Start.class.wait();
                }
            }
        } catch (Throwable e) {
            logger.error("start auth provider failed.", e);
            return;
        }
    }
}
